import { createRouter, createWebHistory } from 'vue-router'
import Index from '../layout/IndexLayout.vue'
import Details from '../view/Details.vue'
import Collections from '../view/Collections.vue'
import Records from '../view/Records.vue'
import Stars from '../view/Stars.vue'
import Apply from '../view/ApplyList.vue'

import Sign from '../layout/SignLayout.vue'
import Login from '../view/Login.vue'
import AdminLogin from '../view/AdminLogin.vue'
import Register from '../view/Register.vue'

const indexChildren = [
    {
        path: '/user/details',
        name: '个人信息',
        component: Details
    },
    {
        path: '/user/collections',
        name: '收藏夹',
        component: Collections
    },
    {
        path: '/user/records',
        name: '浏览记录',
        component: Records
    },
    {
        path: '/user/stars',
        name: '关注列表',
        component: Stars
    },
    {
        path: '/user/apply',
        name: '申请列表',
        component: Apply
    }
]

const signChildren = [
    {
        path: '/user/sign/login',
        name: '登录',
        component: Login
    },
    {
        path: '/user/sign/admin',
        name: '管理员登录',
        component: AdminLogin
    },
    {
        path: '/user/sign/register',
        name: '注册',
        component: Register
    }
]

const routes = [
    {
        path: '/user',
        name: '个人中心',
        component: Index,
        children: indexChildren,
        redirect: '/user/details',
    },
    {
        path: '/user/sign',
        name: '登录',
        component: Sign,
        children: signChildren
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes: routes
})

export default router